﻿using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;


public class UIManagerProxy : MonoBehaviour
{
    private UIManager UiManager;

    private bool isDeckDispanelPanelPushed = false;
    
    private void Awake()
    {
        UiManager = FindObjectOfType<UIManager>().gameObject.GetComponent<UIManager>();
    }

    public void DisplayNewGamePanelProxy()
    {
        UiManager.DisplayNewGamePanel();
    }

    public void DisplayDeckPanelProxy()
    {
        UiManager.DisplayDeckDisplayerPanel();
    }

    public void DisplayRewardPanel(bool isNeedBackMapScene)
    {
        UiManager.DisplayRewardListPanel(isNeedBackMapScene);
    }

    public void SwitchToMapPanelProxy()
    {
        UiManager.SwitchToDeckPanel(isMap:true);
        
        GameObject.FindWithTag(StaticDataManager.MAP_DISPLAY_PANEL_TAG).GetComponent<UIPanel>().isActive = true;
        
        EnableAllOtherButton();
        DisableCurrentButton();
    }
    
    public void SwitchToDeckPanelProxy()
    {
        if (!isDeckDispanelPanelPushed)
        {
            UiManager.PushPanel(GameObject.FindWithTag(StaticDataManager.DECK_DISPLAY_PANEL_TAG));
            isDeckDispanelPanelPushed = true;
        }

        GameObject.FindGameObjectWithTag(StaticDataManager.DECK_DISPLAY_PANEL_TAG).GetComponent<UIPanel>().isActive = true;

        UiManager.FlushDeckPanel(null);
        
        UiManager.SwitchToDeckPanel(isMap:false);

        EnableAllOtherButton();
        DisableCurrentButton();
    }

    public void EnableAllOtherButton()
    {
        foreach (var uiManagerProxy in GameObject.FindObjectsOfType<UIManagerProxy>())
        {
            uiManagerProxy.GetComponent<Button>().enabled = true;
        }
    }

    public void DisableCurrentButton()
    {
        GetComponent<Button>().enabled = false;
    }
}
